//
// Created by dave on 18-7-29.
//
#pragma once

#include "../msg_body.h"
#include "../data_utils.h"

class PlatCommonResp : public MsgBody {
public:
    std::vector<char> encode() override {
        std::vector<char> ret;
        write_word(ret, termSeqNo_);
        write_word(ret, termMsgId_);
        ret.push_back(result_);
        return ret;
    }

    void decode(std::vector<char> data, std::size_t start, std::size_t stop) override {
        termSeqNo_ = read_word(data, start);
        termMsgId_ = read_word(data, start + 2);
        result_ = data[4];
    }

    unsigned short getTermSeqNo() const { return termSeqNo_; }
    void setTermSeqNo(unsigned short termSeqNo) { this->termSeqNo_ = termSeqNo; }

    unsigned short getTermMsgId() const { return termMsgId_; }
    void setTermMsgId(unsigned short termMsgId) { this->termMsgId_ = termMsgId; }

    char getResult() const { return result_; }
    void setResult(char result) { this->result_ = result; }

private:
    /// 终端消息流水号
    unsigned short termSeqNo_;
    /// 终端消息ID
    unsigned short termMsgId_;
    /// 0：成功／确认，1：失败，2：消息有误，3：不支持，4：报警处理确认
    char result_;
};